home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
HamCall (October 1991)
/
HamCall (Whitehall Publishing)(1991).bin
/
util
/
snr
/
snr.doc
< prev
next >
Wrap
Text File
|
1990-10-14
|
11KB
|
206 lines
TITLE: SNR.EXE VERSION: 1.5
PURPOSE: Multi-string text Search 'N' Replace
DATE: 2/23/88
AUTHOR: Thomas A. Lundin
Graphics Unlimited Inc.
3000 2nd St. N.
Minneapolis, MN 55411
(612) 588-7571
DONATION: $10 requested
DESCRIPTION: SNR is a multi-string text search-and-replace filter. Non-text
files can also be processed by the program, since SNR allows
the definition of hex values in a search-and-replace equation.
Up to 50 equations can be entered into an SNR table, each of
which can be 140 characters in length (70 on the search side,
and 70 on the replacement side).
OPERATION: The command line invocation is:
snr [@]filename ext tablename [/d] ─┘
1. "filename" is any unambiguous DOS path/file name. An
optional at-sign (@) in front of the filename indicates
that multiple files are to be processed from a directory
list file, i.e., a file that has been created from a
redirected DIR command. For example, the DOS command
dir *.txt >dirfile ─┘
will create a disk file named "dirfile" which contains a
directory of all files with a ".TXT" extension.
2. "ext" is the filename extension you wish to assign each
output file. The output files are created using the name
of the input file plus the extension specified here. The
choice of an extension is important; if you accidentally
choose an extension which is already used by an input
file, the result of the process is indeterminable,
although file data loss is likely to occur. Use an
extension which is sure to be unique.
Extensions can be the DOS device names CON, NUL, AUX, and
PRN.
3. "tablename" is the unambiguous DOS path/file name which
contains the string translation "equations". Although no
restrictions are placed upon the tablename, for sake of
clarity it is suggested that you adopt a consistent naming
scheme for them, (say, with an *.SNR extension). Tables
are discussed in more detail below.
4. "/d" is an option which replaces the original input file
with the converted data. The EXT specified on the
command line is thus used temporarily until the conversion
is complete, at which time the program performs an
internal file delete/rename operation.
EXAMPLES...
C>snr tstfil.doc txt tst.snr ─┘
The above command line will process some input file
"tstfil.doc" and create an output file "tstfil.txt" using some
table "tst.snr".
C>snr @dirlist p1 sample.snr ─┘
The above command line will process some group of files
contained in the directory list "dirlist" and create some group
of output files with extensions of *.p1 using some table
"sample.snr".
TABLES...
SNR tables are ASCII text files which contain the search-and-
replace equations used by the program. Up to 50 of these
equations can be entered in a single table; each equation can
consist of 70 characters on the search side, and 70 characters
on the replacement side. Blank lines will be ignored by the
table processor. A sample equation would be:
Now is the time=NOW IS THE TIME
It should be obvious that this equation will translate an
upper-and-lower case version of the words "now is the time" to
an all-upper-case string. Notice that spaces ARE SIGNIFICANT
characters in an equation. A search string can be defined to
output nothing, simply by leaving out a replacement string:
Now is the time=
If spaces are desired at the end of a replacement string, they
can be defined as hex codes:
Now is the time =NOW IS THE TIME\20
Any hex code can be formed from a backslash followed by two hex
digits (0-9, a-f, A-F). For instance, a carriage return/line
feed sequence can be specified like this:
\0d\0a\0d\0a=\0d\0a
The above equation will convert two CRLFs in a row to a single
CRLF. A consequence of the backslash notation is that the
backslash itself must be specified in a string as \5c.
Likewise, the equals sign must be specified in a string as \3d.
The null character (\00) is a special case. You should define
it only as a single-character equation, to be converted to
something else or ignored:
\00=\20 \ convert NULL to SPACE
Internal limitations of SNR prevent using the NULL character as
part of a larger search string.
The end of a table is signified by a \\E on a line by itself.
This code is optional, but recommended, since it will prevent
the table processor from inadvertently reading past the end of
your equations (some word processors may pad their last blocks
with garbage, which the table processor would attempt to read
as equation data).
Comments can be entered in a table as lines by themselves, or
set off from an equation:
\ This is a comment line by itself.
\ A comment consists of a single backslash
\ followed by one or more spaces.
\0d\0a=\0d\0a \ this will ensure that existing CRLF pairs are
\ left untouched
\0d=\0d\0a \ this equation will convert an isolated CR
\ into a CRLF
\0a=\0d\0a \ this equation will convert an isolated LF
\ into a CRLF
\\E
Equation ordering is for the most part immaterial, except in
the case where several search strings begin with the same
character. For these occurrences, the strings must be ordered
by length, longest search pattern to shortest (the above
example demonstates this).
See the sample tables for more clarification.
NOTES: The program must reside in a subdirectory defined in a PATH
command, or it must reside in the current subdirectory. (It
reads itself for certain runtime parameters.)
SNR will perform admirably when processing a table whose
search-and-replace strings occur infrequently in a file. The
greater the incidence of search matches, the slower the program
will run.
MACHINE: The program will run on any IBM PC/XT/AT series computer using
MS-DOS 2.x or higher, with a minimum of 128K RAM.
DISCLAIMER: This program is distributed as user-supported software. Use
it, copy it, give it to your friends. Please distribute the
program in ARC form, including all document and sample files.
No warranties, either expressed or implied, are given by the
author or distributor of the program, and the user accepts all
risk of damage arising out of the application and use of the
program.
BEG: If you like the program, contributions in any amount ($10
requested) will be gratefully accepted. Please make checks
payable to Thomas A. Lundin.
A search-and-replace utility that imposes none of the
restrictions of SNR is available as a commercial program named
SuperConverter. For $99, SuperConverter allows up to 1,600
search-and-replace equations to be defined in a table, each of
which can consist of up to 1,000 characters. SuperConverter can
process files at speeds up to 30,000 cps on AT-class machines,
although the nominal conversion rate is roughly 2,500 cps.
SuperConverter supports wild card string matching, preprocessor
setup definitions, and flag states in conversion strings.
SuperConverter is an entirely different program from SNR; they
share no program code. Commercial purchasers will receive a
printed manual and sample tables. For more information, call me
at the number listed below (8am-5pm Central Time, Mon-Fri).
Send comments/bug reports/contributions to:
╔══════════════════════════╗
║ Thomas A. Lundin ║
║ Graphics Unlimited, Inc. ║
║ 3000 Second Street North ║
║ Minneapolis, MN 55411 ║
║ (612) 588-7571 ║
╚══════════════════════════╝
You can also reach me at my BBS home base:
PC-ROCKLAND BBS
If you can't find a program here,
it probably doesn't exist!
(914) 353-2176
(Leave msg. for "Tom Lundin")
Thank you for using SNR.